package com.qfedu.stussm.controller;

import com.qfedu.stussm.entity.Scard;
import com.qfedu.stussm.entity.Student;
import com.qfedu.stussm.service.intf.ScardService;
import com.qfedu.stussm.vo.PageBeanVo;
import com.qfedu.stussm.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/***
 *  .--,       .--,
 * ( (  .---./  ) )
 *  '.__/o   o\__.'
 *     {=  ^  =}
 *      >  -  <
 *     /       
 *    //       \
 *   //|   .   |\
 *   "'       /'"_.-~^`'-.
 *        _  /--'         `
 *    ___)( )(___
 *   (((__) (__)))    高山仰止,景行行止.虽不能至,心向往之。
 */
@Controller
@RequestMapping("/api/scard/")
public class ScardController {
    @Autowired
    private ScardService service;

    //查询
    @GetMapping("all.do")
    @ResponseBody
    public List<PageBeanVo> all(){
        return service.selectAll();
    }
    @GetMapping("page.do")
    @ResponseBody
    public PageBeanVo page(String stu_name, int page, int limit){
        System.out.println(stu_name);
        return service.queryPage(stu_name,page, limit);
    }
    //添加
    @PostMapping("save.do")
    public String save(Scard scard){
        service.add(scard);
        System.out.println(scard);
        return "redirect:/scardlist.html";
    }
    //修改
    @PostMapping("update.do")
    @ResponseBody
    public R update(Scard scard){
        return service.update(scard);
    }
    //删除
    @PostMapping("del.do")
    @ResponseBody
    public R delete(int id){
        return service.del(id);
    }
}
